<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
    <div class="time"></div>
    <script>
          /* 求距离考试结束时间的时分秒,事实显示到页面上
        例如  12-34-46
         */
        show()
        setInterval(show,1000)
        function show(){
            var nowTime = +new Date()
            var time = "2021/10/22 16:50:00"
            var endTime = +new Date(time)
            var gapTime = (endTime-nowTime)/1000;
            var d = Math.floor(gapTime/60/60/24);
            console.log(d)
            var h = Math.floor(gapTime/60/60%24);
            var m = Math.floor(gapTime/60%60);
            var s = Math.floor(gapTime%60);
            var sum = handleNum(d)+":"+handleNum(h)+":"+handleNum(m)+":"+handleNum(s);
            $('.time').text(sum)
        }
        function handleNum(num){
            num = num<10?"0"+num:num
            return num;
        }
    </script>
</body>
</html>